package com.dk.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dk.data.Result;
import com.dk.data.ResultEnum;
import com.dk.service.item.ItemService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("item")
public class ItemController {

    private final Logger logger = LoggerFactory.getLogger(ItemController.class);

    @Reference
    private ItemService itemService;

    @RequestMapping("getItemById")
    @ResponseBody
    public Result getItemById(Long itemId) {
        try {
            return Result.response(ResultEnum.OK).setData(itemService.getItemById(itemId));
        } catch (Exception e) {
            logger.error("获取商品是错误",e);
            return Result.response(ResultEnum.FAIL);
        }
    }

}
